extends StateBase


var player:PlayerScript
var enemyAttacker


func enterState(ownerNode):
	player = ownerNode as PlayerScript
	enemyAttacker = player.enemyAttacker
	
	var dir = sign(enemyAttacker.global_position.x - player.global_position.x) 
	
	player.velocity.y = player.HIT_VELOCITY_Y
	player.velocity.x = player.HIT_VELOCITY_X * -dir
	
	player.animationPlayer.play("HitFlash")
	
	
func exitState(ownerNode):
	pass
	
	
func process(delta, ownerNode):
	pass
	
	
func physicsProcess(delta, ownerNode):
	if not player.is_on_floor():
		player.velocity.y += player.gravity * player.gravityScale * delta
	
	player.move_and_slide()
	
	if player.is_on_floor():
		if player.health <= 0:
			stateMachine.changeState("StateDead", ownerNode)
		else:
			player.hittable = true
			stateMachine.changeState("StateNormal", ownerNode)

